package com.snopy;

import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.exception.InvalidConfigurationException;
import org.mybatis.generator.internal.DefaultShellCallback;

import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * @author snopy
 * @version 1.0.0
 * @classname MybatsiGenerator
 * @description
 * @email 77912204@qq.com
 * @date 2022/03/22 15:54
 */
public class MybatsiGenerator {
    public void test()throws Exception{
        List<String> warnings = new ArrayList<String>();
        boolean overwrite = true;
        File configFile = new File("F:\\workspaceA\\Sonata\\Sonata_mybatis\\src\\main\\resources\\generatorConfig.xml");

        ConfigurationParser cp = new ConfigurationParser(warnings);
        Configuration config = cp.parseConfiguration(configFile);
        DefaultShellCallback callback = new DefaultShellCallback(overwrite);
        MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
        myBatisGenerator.generate(null);
    }
    public static void main(String[] args)  {
        MybatsiGenerator mybatsiGenerator = new MybatsiGenerator();
        try {
            mybatsiGenerator.test();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
